home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10039 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: cph-2.news.DK.net!dkuug!dknet!usenet
  2. From: Brian Elgaard <elgaard@dk-online.dk>
  3. Newsgroups: comp.lang.c++
  4. Subject: A question of (lexical) style
  5. Date: 5 Mar 96 19:45:00 GMT
  6. Organization: Customer at DKnet
  7. Message-ID: <313c99bc.0@193.89.47.9>
  8. NNTP-Posting-Host: h9.dk-online.dk
  9.  
  10. A question of (lexical) style
  11.  
  12. I am currently writing guidelines for C++ programmers, and I am in doubt about how to place * and & in declarations.
  13.  
  14. I prefer to put the type modifier close to the type, such as in:
  15.  
  16.   int& Foo()
  17.   {
  18.     int* a;
  19.     int& b = a;
  20.   }
  21.  
  22. This seems natural to me if declarations with modifiers are restricted to declare a single variable.
  23.  
  24. However, Dan Saks wrote in the C/C++ Users Journal Dec 95:
  25.  
  26.   "I believe most C++ programmers put the *s and &s with the decl-specifier because that's the way Bjarne Stroustrup (the inventor of C++) has always done it. This, in fact, is usually the way you can tell a "real" C++ programmer from a C hack using C++. "Real" C++ programmers do it Stroustrup's way. Too bad he does it wrong."
  27.  
  28. I believe that there is no such thing as a "wrong way" do do it. It is simply a question of taste and style.
  29.  
  30. But I would very much like to hear opinions on which style would be preferable to not-so-experienced C++ programmers.
  31.  
  32.  
  33. Sincerely,
  34.  
  35. Brian Elgaard
  36.